package be.myandroid.games;

import java.util.ArrayList;

import android.util.Log;
import android.view.MotionEvent;

public class TouchManager {
	private static TouchManager instance;
	private static String TAG = "TouchManager";
	private ArrayList<touchListener> listeners = new ArrayList<TouchManager.touchListener>();
	
	private TouchManager(){
		
	}
	
	public static TouchManager getInstance(){
		if(instance != null)
			return instance;
		instance = new TouchManager();
		return instance;
	}
	
	public void OnTouchEvent(float xPos, float yPos, int event){
        switch (event) {
        case MotionEvent.ACTION_DOWN:
    		for (touchListener listener : listeners) {
    			listener.OnClick(xPos,yPos);
    		}
    		Log.d(TAG, "TouchDown at x:" + xPos + " y:" + yPos);
        }
	}
	
	public interface touchListener{
		public void OnClick(float xPos, float yPos);
	}

	public void addListener(touchListener listener) {
		listeners.add(listener);
	}
}
